<template>
  <div class="app-container">
    <div style="display: flex;width: 100%;margin-bottom: 10px" v-if="unionList && unionList.length > 0">
      <template v-for="item in unionList">
        <div class="currency">
          <div class="flex-justify-between" style="gap:8px">
            <img v-if="item.currency == 'USD'" src="@/assets/va/usd.png" style="width: 32px;height: 32px" alt="flag"/>
            <img v-if="item.currency == 'EUR'" src="@/assets/va/eur.png" style="width: 32px;height: 32px" alt="flag"/>
            <img v-if="item.currency == 'CNH'" src="@/assets/va/cnh.png" style="width: 32px;height: 32px" alt="flag"/>
            <img v-if="item.currency == 'USDT'" src="@/assets/va/usdt.png" style="width: 32px;height: 32px" alt="flag"/>
            <div style="display: flex;flex-direction: column;flex: 1;">
              <div class="flex-justify-between" style="font-size: 18px;font-weight: 500;line-height: 24px;">
                <span>{{ item.currency }}</span><span>{{ item.charge }}</span>
              </div>
              <div class="flex-justify-between"
                   style="color: #86909c;font-size: 14px;font-weight: 400;line-height: 20px;">
                <span v-if="item.currency == 'USD'">美元</span>
                <span v-else-if="item.currency == 'EUR'">欧元</span>
                <span v-else-if="item.currency == 'CNH'">离岸人民币</span>
                <span v-else-if="item.currency == 'USDT'">USDT</span>
                <span v-else>{{ item.currency }}</span>
                <span>入账总额</span>
              </div>
            </div>
          </div>
        </div>
      </template>
    </div>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="开始日期" prop="day">
        <el-date-picker clearable
                        v-model="queryParams.$ge_day"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="结束日期" prop="day">
        <el-date-picker clearable
                        v-model="queryParams.$le_day"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['va:stat:query']"
        >导出
        </el-button>
      </el-form-item>
      <br/>
      <el-form-item v-if="checkPermi(['platop'])" label="代理" prop="parentName">
        <el-input
          v-model="queryParams.parentName"
          placeholder="输入代理名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item v-if="checkPermi(['platop'])" label="商户号" prop="mchNo">
        <el-input
          v-model="queryParams.mchNo"
          placeholder="输入商户号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item v-if="checkPermi(['platop'])" label="商户名" prop="mchName">
        <el-input
          v-model="queryParams.mchName"
          placeholder="输入商户名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

    </el-form>

    <el-table v-loading="loading" :data="statList">
      <el-table-column v-if="checkPermi(['platop'])" label="代理" align="center" prop="parentName"/>
      <el-table-column v-if="checkPermi(['platop'])" label="商户" align="center" width="200">
        <template slot-scope="scope">
          <p>
            <span style="color: rgb(114, 158, 213); border-radius: 1px; padding: 3px 7px; height: auto; width: auto;">商户号</span>
            <span>{{ scope.row.mchNo }}</span>
          </p>
          <p>
            <span
              style="color: rgb(86, 207, 86); border-radius: 1px; padding: 3px 7px; height: auto; width: auto;">名称</span>
            <span>{{ scope.row.mchName }}</span>
          </p>
        </template>
      </el-table-column>
      <el-table-column label="日期" align="center" width="210">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.day, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="币种" align="center" prop="currency">
      </el-table-column>
      <el-table-column label="入账" align="center" prop="charge">
      </el-table-column>
      <el-table-column label="兑出" align="center" prop="exOut">
      </el-table-column>
      <el-table-column v-if="checkPermi(['platop'])" label="利润" align="center" prop="exPro">
      </el-table-column>


    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {queryBisonStat} from "@/api/fusion/va/module/bison";

export default {
  name: "bison-stat",
  data() {
    return {
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      statList: [],
      // 弹出层标题
      title: "",
      unionList: [],
      queryParams: {
        isAsc: 'desc',
        orderByColumn: 'id',
        pageNum: 1,
        pageSize: 10,
        provider: 'bison',
      },

    };
  },
  created() {
    this.getList();
  },
  methods: {

    /** 查询VA提款转载列表 */
    getList() {
      this.loading = true;
      queryBisonStat(this.queryParams).then(response => {
        this.statList = response.rows;
        this.total = response.total;
        this.loading = false;
        this.unionList = response.ext.unionList
      });
    },
    // 取消按钮
    cancel() {
      this.openWithdraw = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {};
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.queryParams.provider = 'bison'
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.state = ''
      this.handleQuery();
    },
    handleExport() {
      this.download('va/stat/export', {
        ...this.queryParams
      }, `贝森数据统计_${new Date().getTime()}.xlsx`)
    }

  }
};
</script>
<style scoped>
.flex-justify-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.currency {
  background-color: rgb(245, 245, 245);
  display: flex;
  flex-direction: column;
  width: 300px;
  padding: 20px;
  box-sizing: border-box;
  border: 1px solid #f2f3f5;
  border-radius: 8px;
  margin-right: 12px;
}
</style>
